<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('表格行内编辑')" />
	<th:block th:include="include :: bootstrap-editable-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="btn-group-sm" id="toolbar" role="group">

			<a class="btn btn-primary" onclick="openChildBudgetTable()">
				<i class="fa button"></i> 添加实际
			</a>
        </div>
		<div class="row">
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: bootstrap-table-editable-js" />
	
    <script th:inline="javascript">
        var prefix = ctx + "system/actual";
        var datas = [[${@dict.getType('sys_normal_disable')}]];
        var stageId = [[${stageId}]];
        $(function() {
            var options = {
                url: prefix + "/listTable/"+ stageId,
		        showSearch: false,
		        showRefresh: true,
		        showToggle: false,
		        showColumns: false,
		        showPageGo: true,
		        onEditableSave: onEditableSave,
                columns: [{
		            checkbox: true
		        },


                    {
                        field : 'id',
                        title : '主键id',
                        visible: false
                    },
                    {
                        field : 'contractId',
                        title : '合同id'
                    },
                    {
                        field : 'stageId',
                        title : '阶段id'
                    },

                    {
                        field : 'actualMoney',
                        title : '实际收款金额',
                        editable: true
                    },
                    {
                        field : 'actualTime',
                        title : '实际收款时间',
                        editable: true
                    },


		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="delThisline(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');

                        return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        function onEditableSave (field, row, oldValue, $el) {
        	// alert(row.id + "字段名：" + field + "，当前值：" + row.actualMoney + row.actualTime  + "，旧值：" + oldValue);
            $.operate.save(prefix + "/editOneLine/"+row.id +"/"+ row.actualMoney+"/"+ row.actualTime, $('#form-budget-edit').serialize());
        }
        
        
        function delThisline(rowId) {
            $.operate.save(prefix + "/remove/"+rowId, $('#form-budget-add').serialize());
        }

        var prefixSystem = ctx + "system"
        openChildBudgetTable = function() {
            $.modal.openOptions({
                title: '添加实际',
                width: "680",
                url: prefixSystem + "/actual/add/" + stageId,
                callBack: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                }
            });
        }
        
    </script>
</body>
</html>